﻿using Microsoft.AspNetCore.Mvc;

namespace Magic.Web.Entry;

/// <summary>
/// 缓存服务
/// </summary>
public class CacheController: BaseController
{
    private readonly IMemberCacheService _cacheService;
    public CacheController(IMemberCacheService cacheService)
    {
        _cacheService = cacheService;
    }
    /// <summary>
    /// 设置缓存
    /// </summary>
    /// <param name="key"></param>
    /// <returns></returns>
    [HttpPost("/admin/cache/set")]
    public async Task SetCache(string key,object value)
    {
        await _cacheService.Set(key,value);
    }
    /// <summary>
    /// 获取缓存
    /// </summary>
    /// <param name="key"></param>
    /// <returns></returns>
    [HttpGet("/admin/cache/get")]
    public async Task<dynamic> GetCache(string key)
    {
        return await _cacheService.Get(key);
    }
}
